package com.soso.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@Entity
@Table(name="modules")
public class Modules {
	@Id
	@GeneratedValue
	private Integer Id;
	@JsonIgnoreProperties("modules")

	@ManyToMany(targetEntity = Roles.class,fetch = FetchType.EAGER)//即时加载
	            //指定第三张表的名称                   //指定在中间表中与id的对应关系
	@JoinTable(name="Rolemodules",joinColumns = {@JoinColumn(name="ModuleId")},
	//另一张表的主键与中间表的对应关系
	inverseJoinColumns = {@JoinColumn(name="RoleId")})
	@NotFound(action = NotFoundAction.IGNORE)
	private List<Roles> roles=new ArrayList<Roles>();
	private String title;
	private Integer ParentId;
	private String href;
	private Integer Weight;
	private String icon_class;
	private String Ops;
	private Integer Int0;
	@Transient
	private List<Modules> children;
	@Transient
	private boolean checked;
	public Integer getId() {
		return Id;
	}
	public void setId(Integer id) {
		Id = id;
	}
	public List<Roles> getRoles() {
		return roles;
	}
	public void setRoles(List<Roles> roles) {
		this.roles = roles;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Integer getParentId() {
		return ParentId;
	}
	public void setParentId(Integer parentId) {
		ParentId = parentId;
	}
	public String getHref() {
		return href;
	}
	public void setHref(String href) {
		this.href = href;
	}
	public Integer getWeight() {
		return Weight;
	}
	public void setWeight(Integer weight) {
		Weight = weight;
	}
	public String getIcon_class() {
		return icon_class;
	}
	public void setIcon_class(String icon_class) {
		this.icon_class = icon_class;
	}
	public String getOps() {
		return Ops;
	}
	public void setOps(String ops) {
		Ops = ops;
	}
	public Integer getInt0() {
		return Int0;
	}
	public void setInt0(Integer int0) {
		Int0 = int0;
	}
	public List<Modules> getChildren() {
		return children;
	}
	public void setChildren(List<Modules> children) {
		this.children = children;
	}
	public boolean isChecked() {
		return checked;
	}
	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	public Modules(Integer id, List<Roles> roles, String title, Integer parentId, String href, Integer weight,
			String icon_class, String ops, Integer int0, List<Modules> children, boolean checked) {
		super();
		Id = id;
		this.roles = roles;
		this.title = title;
		ParentId = parentId;
		this.href = href;
		Weight = weight;
		this.icon_class = icon_class;
		Ops = ops;
		Int0 = int0;
		this.children = children;
		this.checked = checked;
	}
	public Modules() {
		super();
	}
	@Override
	public String toString() {
		return "Modules [Id=" + Id + ", roles=" + roles + ", title=" + title + ", ParentId=" + ParentId + ", href="
				+ href + ", Weight=" + Weight + ", icon_class=" + icon_class + ", Ops=" + Ops + ", Int0=" + Int0
				+ ", children=" + children + ", checked=" + checked + "]";
	}


	
}
